﻿
using Models.Common;
using Newtonsoft.Json;
using UtilsBase;
using UtilsCache;
using Models.Device;
using Models.JsonResultModel;

namespace ServiceWeb.APIRequest
{
    public class ServiceWebRabbitMQSendMsg_UseMethod
    {
        /// <summary>
        /// 发送设备指信信息到云端进行处理
        /// </summary>
        /// <param name="deviceControl"></param>
        /// <returns></returns>
        public bool sendDeviceControlCommand(ModelRequestDeviceControl deviceControl)
        {
            string content = JsonConvert.SerializeObject(deviceControl);
            try
            {
                Console.WriteLine("****************************************");
                Console.WriteLine("内容：" + content.ToString());
                ModelReceverData modelDeviceData = new ModelReceverData();
                modelDeviceData.content = content.ToString();

                MQReqModel<object> mQReqModel = new MQReqModel<object>();
                mQReqModel.respEvent = MQEventEnum.API_DeviceControl;
                mQReqModel.respCode = ResponseCode.SUCCESS;
                mQReqModel.toServerData = modelDeviceData;
                mQReqModel.guid = Guid.NewGuid().ToString();
                new ServiceWebRabbitMQSendMsg().sendMsg(mQReqModel);
                return true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("****************************************");
                Console.WriteLine("内容：" + content.ToString());
                Console.WriteLine("失败");
                Console.WriteLine(ex.ToString());
                Console.WriteLine("****************************************");
            }
            return false;
        }


    }

}
